package ca.qc.bdeb.info.pp2.tp2.application;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

public class VilleDAO
{
    public static List<Ville> listerVille(int idProvince)
    {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        Query query = session.createQuery("from Ville where id_province=:province");
        query.setInteger("province", idProvince);
        return (List<Ville>) (query.list());
    }

    public static Ville getVille(int idVille)
    {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        Ville v = (Ville) (session.get(Ville.class, idVille));

        return v;
    }
}
